package org.moore.view;

import org.moore.utils.Data;

import javax.swing.*;

import java.awt.*;

import static org.moore.utils.Button.getjButton;

// 存档面板类
public class SaveMapPanel extends JLabel {
    // 定义保存存档按钮
    private final JButton saveMapBtn;
    // 定义存档1按钮
    private final JButton save1;
    // 定义存档2按钮
    private final JButton save2;
    // 定义存档3按钮
    private final JButton save3;
    // 定义存档4按钮
    private final JButton save4;
    // 定义存档5按钮
    private final JButton save5;
    // 定义存档6按钮
    private final JButton save6;

    // 定义字体
    private final Font font = new Font("楷体", Font.BOLD,50);

    public SaveMapPanel() {
        // 设置保存存档按钮
        saveMapBtn = getjButton(Data.BUTTON_ICON_2ND, Data.FONT);
        saveMapBtn.setText("保存存档");
        saveMapBtn.setBounds(950,400,200,150);
        saveMapBtn.setActionCommand("saveMap");
        this.add(saveMapBtn);
        // 存档1按钮
        save1 = getjButton(Data.SAVE_INFO_BUTTON, Data.FONT);
        save1.setText(Data.SAVE_TEXT);
        save1.setForeground(Color.BLACK);
        save1.setBounds(30,30,400,200);
        save1.setActionCommand("save1");
        this.add(save1);
        // 存档2按钮
        save2 = getjButton(Data.SAVE_INFO_BUTTON, Data.FONT);
        save2.setText(Data.SAVE_TEXT);
        save2.setForeground(Color.BLACK);
        save2.setBounds(440,30,400,200);
        save2.setActionCommand("save2");
        this.add(save2);
        // 存档3按钮
        save3 = getjButton(Data.SAVE_INFO_BUTTON, Data.FONT);
        save3.setText(Data.SAVE_TEXT);
        save3.setForeground(Color.BLACK);
        save3.setBounds(30,240,400,200);
        save3.setActionCommand("save3");
        this.add(save3);
        // 存档4按钮
        save4 = getjButton(Data.SAVE_INFO_BUTTON, Data.FONT);
        save4.setText(Data.SAVE_TEXT);
        save4.setForeground(Color.BLACK);
        save4.setBounds(440,240,400,200);
        save4.setActionCommand("save4");
        this.add(save4);
        // 存档5按钮
        save5 = getjButton(Data.SAVE_INFO_BUTTON, Data.FONT);
        save5.setText(Data.SAVE_TEXT);
        save5.setForeground(Color.BLACK);
        save5.setBounds(30,450,400,200);
        save5.setActionCommand("save5");
        this.add(save5);
        // 存档4按钮
        save6 = getjButton(Data.SAVE_INFO_BUTTON, Data.FONT);
        save6.setText(Data.SAVE_TEXT);
        save6.setForeground(Color.BLACK);
        save6.setBounds(440,450,400,200);
        save6.setActionCommand("save6");
        this.add(save6);
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        // 使用g2d绘制以修复抗锯齿
        Graphics2D g2d = (Graphics2D) g;
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        // 绘制背景
        g2d.drawImage(Data.SAVE_BACKGROUND,0,0,this.getWidth(),this.getHeight(),null);
        // 绘制标题图片
        g2d.drawImage(Data.SAVE_TITLE,950,50,200,150,null);
        // 设置文字
        g2d.setFont(font);
        // 绘制标题文字
        g2d.drawString("存档管理",950,250);
    }

    public JButton getSaveMapBtn() {
        return saveMapBtn;
    }

    public JButton getSave1() {
        return save1;
    }

    public JButton getSave2() {
        return save2;
    }

    public JButton getSave3() {
        return save3;
    }

    public JButton getSave4() {
        return save4;
    }

    public JButton getSave5() {
        return save5;
    }

    public JButton getSave6() {
        return save6;
    }
}
